package designPattern.action11.Visitor.A2.concrete.visitor;

import java.util.Iterator;

import designPattern.action11.Visitor.A2.concrete.entry.DirectoryEntry;
import designPattern.action11.Visitor.A2.concrete.entry.FileEntry;
import designPattern.action11.Visitor.A2.sketch.Entry;
import designPattern.action11.Visitor.A2.sketch.Visitor;

public class SizeVisitor extends Visitor {
    private int size = 0;

    public int getSize() {
        return size;
    }

    public void visit(FileEntry file) {
        size += file.getSize();
    }

    public void visit(DirectoryEntry directoryEntry) {
        Iterator it = directoryEntry.iterator();
        while (it.hasNext()) {
            Entry entry = (Entry) it.next();
            entry.accept(this);
        }
    }
}
